#!/bin/bash
yum install -y java-1.8.0-openjdk
echo "Install zookeeper..."
wget http://apache.fayea.com/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz -O -c /usr/local/zookeeper.tar.gz
tar zxf /usr/local/zookeeper.tar.gz -C /usr/local/
mv /usr/local/zookeeper-3.4.9 /usr/local/zookeeper
cd /usr/local/zookeeper/conf
cp zoo_sample.cfg zoo.cfg
sed -i 's/dataDir=\/tmp\/zookeeper/dataDir=\/usr\/local\/zookeeper\/data/g' zoo.cfg
echo "datalogDir=/usr/local/zookeeper/logs">>zoo.cfg
cd /usr/local/zookeeper
mkdir data logs
cd data
read -p "Please myid:" MYID
echo "${MYIID}" >myid
/usr/local/zookeeper/bin/zkServer.sh start

echo "Install kafka..."
wget http://apache.fayea.com/kafka/0.10.0.0/kafka_2.11-0.10.0.0.tgz -c -O /usr/local/kafka.tgz
tar zxf /usr/local/kafka.tgz -C /usr/local/
mv /usr/local/kafka_2.11-0.10.0.0/ /usr/local/kafka
cd /usr/local/kafka/config


